/**
 * 
 */
package com.td.framework.webmanager.ryjbxx.action;

import java.util.List;

import com.td.framework.common.AbstractAction;
import com.td.framework.common.Constant;
import com.td.framework.webmanager.bmxx.service.BmxxService;
import com.td.framework.webmanager.domain.AppsysBmxx;
import com.td.framework.webmanager.domain.AppsysDlyh;
import com.td.framework.webmanager.domain.AppsysDmb;
import com.td.framework.webmanager.domain.AppsysRyjbxx;
import com.td.framework.webmanager.ryjbxx.service.RyjbxxService;
import com.opensymphony.xwork2.Action;

/**
 * Title: 人员基本信息Action Description:处理人员基本信息 
 * Copyright: Copyright (c) 2008
 * Company 北京水软科技有限公司
 * @version 1.0
 */
public class RyjbxxAction extends AbstractAction implements Action {

	private static final long serialVersionUID = -8090423183681213983L;
	private RyjbxxService ryjbxxService = null;// 人员信息Service;
	private BmxxService bmxxService = null;// 部门信息Service;
	private List<AppsysRyjbxx> ryxxList = null;// 人员信息List;
	private List<AppsysBmxx> treeList = null;// 生成部门树;
	private List<AppsysDmb> sexList = null;//性别集合;
	private List<AppsysDmb> zwList = null;//职务集合;
	private List<AppsysDmb> xlList = null;//学历集合;
	private AppsysRyjbxx ryjbxx = null;// 人员信息对象;
	private AppsysDlyh appsysDlyh = null;//用户信息;
	private String target = "";// 目标参数;
	private String urlFlag = "";//判断url参数
	private String bmbh = "";// 部门编号;
	private String bmmc = "";//部门名称;
	private String rybh = "";// 人员编号;
	private String rybhs = "";// 多个人员编号;
	private String [] orderRybhs = null;//排序人员编号;
	private String [] pxh = null;//排序号;	
	
	/**
	 * @toDo:人员信息列表
	 * @return target;
	 */
	public String listRyjbxx() {
		ryjbxxService.setSql(bmbh, ryjbxx,this.getUserInfo().getYhbh(),this.getUserInfo().getBmbh(),Constant.SYS_XTBM);
		int rows = ryjbxxService.getRows();
		page = pageService.getPage(rows, currentPage, pageSize, pageMethod);
		this.setCurrentPage(page.getCurentPage());		
		this.setPageSize(page.getPageSize());
		ryxxList = ryjbxxService.findBybmbh(page.getPageSize(), page.getStartRow());
		target = "list";
		if(urlFlag.equals("selRy"))
		{
			target = "selList";
		}else if(urlFlag.equals("selMutiList"))
		{
			target = "selMutiList";
		}
		if(bmbh.equals("-1"))
		{
			//bmbh = "01";
			this.handleMessage("orderFlag", "-1");
		}	
		return target;
	}
	/**
	 * @toDo:通过部门编号查询个人信息;
	 * @return target;
	 */
	@SuppressWarnings("unchecked")
	public String infoRyjbxx() {
		ryjbxx = ryjbxxService.getAppsysRyjbxx(new Long(rybh));
		bmbh =ryjbxxService.getBmbh(ryjbxx.getRybh());
		bmmc = bmxxService.getBmxx(bmbh).getBmmc();
		target = "info";
		return target;
	}
	/**
	 * @toDo:生成部门树;
	 * @return target;
	 */
	@SuppressWarnings("unchecked")
	public String listRybmTree() {
//		treeList = bmxxService.getTreeList();
		treeList = bmxxService.findBmxxByYhbh(this.getUserInfo().getYhbh(),this.getUserInfo().getBmbh(), 1, Constant.SYS_XTBM, 1);
		target = "rybmTree";
		if(urlFlag.equals("selRy"))
		{
			target = "selTree";
		}
		return target;
	}
	/**
	 * @toDo:生成排序人员列表;
	 * @return target;
	 */
	public String listOrderRyjbxx()
	{
		ryxxList = ryjbxxService.findBybmbhs(bmbh, 1);
		target = "orderList";
		return target;
	}
	/**
	 * @toDo:生成添加表单;
	 * @return target;
	 */
	@SuppressWarnings("unchecked")
	public String createRyjbxxForm() {
		if(bmbh.equals("-1"))
		{
			bmbh = "01";
		}	
		bmmc = bmxxService.getBmxx(bmbh).getBmmc();
		sexList=ryjbxxService.findDmbByDmlx(Constant.XB);
		zwList=ryjbxxService.findDmbByDmlx(Constant.ZW);
		xlList=ryjbxxService.findDmbByDmlx(Constant.XL);
		target = "addForm";
		return target;
	}

	/**
	 * @toDo:保存人员信息;
	 * @return target;
	 */
	@SuppressWarnings("unchecked")
	public String createRyjbxx() {
		if (ryjbxxService.addAppsysRyjbxx(ryjbxx,appsysDlyh, bmbh))
		{
			this.handleMessage("info", "添加成功,请继续操作!");
			ryjbxx = new AppsysRyjbxx();
			appsysDlyh = new AppsysDlyh();
			target = "addSuccess";
		}
		else
		{
			this.handleMessage("info", "添加失败,您添加的信息不符合要求,请重新添加!");
			target = "addFailure";
		}
		bmmc = bmxxService.getBmxx(bmbh).getBmmc();
		sexList=ryjbxxService.findDmbByDmlx(Constant.XB);
		zwList=ryjbxxService.findDmbByDmlx(Constant.ZW);
		xlList=ryjbxxService.findDmbByDmlx(Constant.XL);
		return target;
	}

	/**
	 * @toDo:生成修改表单;
	 * @return target;
	 */
	@SuppressWarnings("unchecked")
	public String reworkRyjbxxForm() {
		sexList=ryjbxxService.findDmbByDmlx(Constant.XB);
		zwList=ryjbxxService.findDmbByDmlx(Constant.ZW);
		xlList=ryjbxxService.findDmbByDmlx(Constant.XL);
		ryjbxx = ryjbxxService.getAppsysRyjbxx(new Long(rybhs.split(",")[0]));
		if (ryjbxx != null)
		{
			bmbh = ryjbxxService.getBmbh(ryjbxx.getRybh());
			bmmc = bmxxService.getBmxx(bmbh).getBmmc();
			target = "editForm";
		}
		else
		{
			target = "ryxxList";
		}
		return target;
	}

	/**
	 * @toDo:更新人员信息;
	 * @return target;
	 */
	@SuppressWarnings("unchecked")
	public String reworkRyjbxx() {
		if (ryjbxxService.updateAppsysRyjbxx(ryjbxx, bmbh))
		{
			result ="OK";
		}
		else
		{
			result ="failure";
			this.handleMessage("info", "修改失败,请重新修改!");
		}
		sexList=ryjbxxService.findDmbByDmlx(Constant.XB);
		zwList=ryjbxxService.findDmbByDmlx(Constant.ZW);
		xlList=ryjbxxService.findDmbByDmlx(Constant.XL);
		bmmc = bmxxService.getBmxx(bmbh).getBmmc();
		target = "updateSuccess";
		return target;
	}

	/**
	 * @toDo:删除人员信息;
	 * @return target;
	 */
	public String removeRyjbxx() {
		ryjbxxService.deleteAppsysRyjbxx(rybhs.split(","), bmbh);
		target = "deleteSuccess";
		return target;
	}
	public String orderRyjbxx()
	{
		if(ryjbxxService.orderAppsysRyjbxx(orderRybhs, pxh))
		{
			target = "orderSuccess";
			result ="OK";
		}
		else
		{
			target = "orderFailure";
			this.handleMessage("info", "排序失败,请重新操作!");
			result ="failure";
		}
		return target;
	}

	/**
	 * @toDo:get人员信息Service ;
	 * @return the ryjbxxService
	 */
	public RyjbxxService getRyjbxxService() {
		return ryjbxxService;
	}

	/**
	 * @toDo:set人员信息Service ;
	 * @param ryjbxxService
	 *            the ryjbxxService to set
	 */
	public void setRyjbxxService(RyjbxxService ryjbxxService) {
		this.ryjbxxService = ryjbxxService;
	}

	/**
	 * @toDo:get人员信息List ;
	 * @return the ryxxList
	 */
	public List<AppsysRyjbxx> getRyxxList() {
		return ryxxList;
	}

	/**
	 * @toDo:get人员信息;
	 * @return the ryjbxx
	 */
	public AppsysRyjbxx getRyjbxx() {
		return ryjbxx;
	}

	/**
	 * @toDo:set人员信息 ;
	 * @param ryjbxx
	 *            the ryjbxx to set
	 */
	public void setRyjbxx(AppsysRyjbxx ryjbxx) {
		this.ryjbxx = ryjbxx;
	}

	/**
	 * @toDo:get目标参数 ;
	 * @return the target
	 */
	public String getTarget() {
		return target;
	}

	/**
	 * @toDo:set目标参数 ;
	 * @param target
	 *            the target to set
	 */
	public void setTarget(String target) {
		this.target = target;
	}

	/**
	 * @toDo:get部门编号 ;
	 * @return the bmbh
	 */
	public String getBmbh() {
		return bmbh;
	}

	/**
	 * @toDo:set部门编号 ;
	 * @param bmbh
	 *            the bmbh to set
	 */
	public void setBmbh(String bmbh) {
		this.bmbh = bmbh;
	}

	/**
	 * @toDo:get部门信息Service ;
	 * @return the bmxxService
	 */
	public BmxxService getBmxxService() {
		return bmxxService;
	}

	/**
	 * @toDo:set部门信息Service ;
	 * @param bmxxService
	 *            the bmxxService to set
	 */
	public void setBmxxService(BmxxService bmxxService) {
		this.bmxxService = bmxxService;
	}

	/**
	 * @toDo:get生成部门树 ;
	 * @return the treeList
	 */
	public List<AppsysBmxx> getTreeList() {
		return treeList;
	}

	/**
	 * @toDo:set生成部门树 ;
	 * @param treeList
	 *            the treeList to set
	 */
	public void setTreeList(List<AppsysBmxx> treeList) {
		this.treeList = treeList;
	}

	/**
	 * @toDo:get多个人员编号 ;
	 * @return the rybhs
	 */
	public String getRybhs() {
		return rybhs;
	}

	/**
	 * @toDo:set多个人员编号 ;
	 * @param rybhs
	 *            the rybhs to set
	 */
	public void setRybhs(String rybhs) {
		this.rybhs = rybhs;
	}

	/**
	 * @toDo:get人员编号;
	 * @return the rybh
	 */
	public String getRybh() {
		return rybh;
	}

	/**
	 * @toDo:set人员编号;
	 * @param rybh
	 *            the rybh to set
	 */
	public void setRybh(String rybh) {
		this.rybh = rybh;
	}

	/**
	 * @toDo:set ;
	 * @param ryxxList
	 *            the ryxxList to set
	 */
	public void setRyxxList(List<AppsysRyjbxx> ryxxList) {
		this.ryxxList = ryxxList;
	}
	/**
	 * @toDo:get用户信息;
	 * @return the appsysDlyh
	 */
	public AppsysDlyh getAppsysDlyh() {
		return appsysDlyh;
	}
	/**
	 * @toDo:set用户信息;
	 * @param appsysDlyh the appsysDlyh to set
	 */
	public void setAppsysDlyh(AppsysDlyh appsysDlyh) {
		this.appsysDlyh = appsysDlyh;
	}
	/**
	 * @return the sexList
	 */
	public List<AppsysDmb> getSexList() {
		return sexList;
	}
	/**
	 * @param sexList the sexList to set
	 */
	public void setSexList(List<AppsysDmb> sexList) {
		this.sexList = sexList;
	}
	/**
	 * @return the zwList
	 */
	public List<AppsysDmb> getZwList() {
		return zwList;
	}
	/**
	 * @param zwList the zwList to set
	 */
	public void setZwList(List<AppsysDmb> zwList) {
		this.zwList = zwList;
	}
	/**
	 * @return the xlList
	 */
	public List<AppsysDmb> getXlList() {
		return xlList;
	}
	/**
	 * @param xlList the xlList to set
	 */
	public void setXlList(List<AppsysDmb> xlList) {
		this.xlList = xlList;
	}
	/**
	 * @return the orderRybhs
	 */
	public String[] getOrderRybhs() {
		return orderRybhs;
	}
	/**
	 * @param orderRybhs the orderRybhs to set
	 */
	public void setOrderRybhs(String[] orderRybhs) {
		this.orderRybhs = orderRybhs;
	}
	/**
	 * @return the pxh
	 */
	public String[] getPxh() {
		return pxh;
	}
	/**
	 * @param pxh the pxh to set
	 */
	public void setPxh(String[] pxh) {
		this.pxh = pxh;
	}
	/**
	 * @return the bmmc
	 */
	public String getBmmc() {
		return bmmc;
	}
	/**
	 * @param bmmc the bmmc to set
	 */
	public void setBmmc(String bmmc) {
		this.bmmc = bmmc;
	}
	/**
	 * @return the urlFlag
	 */
	public String getUrlFlag() {
		return urlFlag;
	}
	/**
	 * @param urlFlag the urlFlag to set
	 */
	public void setUrlFlag(String urlFlag) {
		this.urlFlag = urlFlag;
	}
	public String getResult() {
		return result;
	}
	public void setResult(String result) {
		this.result = result;
	}
}
